package com.fgw.controller.backend;

import com.fgw.common.Const;
import com.fgw.common.ResponseCode;
import com.fgw.common.ServerResponse;
import com.fgw.pojo.Teacher;
import com.fgw.service.IPxtonzhiService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

/**
 * Created by lyj on 2017/9/8.
 */
@Controller
@RequestMapping("/admin/Pxtonzhi/")
public class PxtonzhiAdminController {

    @Autowired
    private IPxtonzhiService iPxtonzhiService;

    /**
     * 后端培训通知列表Controller
     * @return
     */
    @RequestMapping(value = "list.do",method = RequestMethod.POST)
    @ResponseBody
    public ServerResponse<PageInfo> getNeedPxtongzhiList(HttpSession session, @RequestParam(value = "pageNum",defaultValue = "1") int pageNum, @RequestParam(value = "pageSize",defaultValue = "5")int pageSize ){

        Teacher teacher= (Teacher) session.getAttribute(Const.CURRENT_USER);
        if(teacher==null){
            return  ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(),"用户未登录，请先登录！");
        }else {

            return iPxtonzhiService.getPxtonzhiManagerList(pageNum, pageSize, 1);
        }
    }

    /**
     * 查询已经关闭的报名
     * @param session
     * @param pageNum
     * @param pageSize
     * @return
     */
    @RequestMapping(value = "close_list.do",method = RequestMethod.POST)
    @ResponseBody
    public ServerResponse<PageInfo> getTeacherAsCloseList(HttpSession session, @RequestParam(value = "pageNum",defaultValue = "1") int pageNum, @RequestParam(value = "pageSize",defaultValue = "5")int pageSize ){

        Teacher teacher= (Teacher) session.getAttribute(Const.CURRENT_USER);
        if(teacher==null){
            return  ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(),"用户未登录，请先登录！");
        }else {

            return iPxtonzhiService.getPxtonzhiManagerList(pageNum, pageSize,2);
        }
    }



}
